package com.imooc.order.fallback.addressservice;

import com.imooc.user.pojo.UserAddress;
import com.imooc.user.pojo.bo.AddressBo;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author 顾志杰
 * @date 2020/9/14-15:44
 */
@Component
public class AddressServiceFallbackFactory implements FallbackFactory<AddressServiceFeignClient> {
    @Override
    public AddressServiceFeignClient create(Throwable throwable) {
        return new AddressServiceFeignClient() {
            @Override
            public List<UserAddress> queryAll(String userId) {
                throw new RuntimeException("系统维护");
            }

            @Override
            public void addNewUserAddress(AddressBo addressBo) {
                throw new RuntimeException("系统维护");
            }

            @Override
            public void updateUserAddress(AddressBo addressBo) {
                throw new RuntimeException("系统维护");
            }

            @Override
            public void deleteUserAddress(String userid, String addressId) {
                throw new RuntimeException("系统维护");
            }

            @Override
            public void setDefalutUserAddress(String userid, String addressId) {
                throw new RuntimeException("系统维护");
            }

            @Override
            public UserAddress queryUserAddress(String userId, String addressId) {
                throw new RuntimeException("系统维护");
            }
        };
    }
}
